package com.example.redis.mapper;

import com.example.redis.bean.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

/**
 * Copyright(C), 2020-2021, AmbroseCdMeng
 * FileName:    UserMapper
 * Author:      AmbroseCdMeng
 * Date:        2021/2/26 16:28
 * Description: 实体和数据表的映射关系
 * History:
 * <author>     <time>      <version>       <desc>
 * 作者姓名     修改时间        版本号           描述
 */
@Repository
@Mapper
public interface UserMapper {
    @Insert("insert into user(name, age) values (#{name}, #{age})")
    int addUser(@Param("name")String name, @Param("age")String age);

    @Select("select * from user where id = #{id}")
    User findById(@Param("id") String id);

    @Update("update user set name = #{name}, age = #{age} where id = #{id}")
    int updateById(User user);

    @Delete("delete from user where id = #{id}")
    void deleteById(@Param("id")String id);
}
